<!--
 * @Description: 修改商品分类弹窗
 * @Author: liyujie
 * @Date: 2021/07/07
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/07/07
-->
<template>
    <section class="wrapper">
        <el-dialog
            title="修改分类"
            :visible.sync="dialogVisible"
            width="520px"
            :close-on-click-modal="false"
            @close="handleClose"
        >
            <div class="dialog-content">
                <div class="form-item">
                    <p style="margin-right: 10px;">分类</p>
                    <el-cascader
                        placeholder="请选择商品分类"
                        :options="typeList"
                        filterable
                        clearable
                        size="small"
                        expand-trigger="click"
                        v-model="type_name"
                        :props="{
                            label: 'title',
                            value: 'no',
                            children: 'children'
                        }"
                        style="width: 350px"
                    />
                </div>
            </div>
            <div class="dialog-footer">
                <el-button
                    size="medium"
                    style="width: 120px"
                    @click="dialogVisible = false"
                >
                    取消
                </el-button>
                <el-button
                    type="primary"
                    size="medium"
                    style="width: 120px;margin-left: 52px"
                    @click="handleConfirm"
                >
                    确定
                </el-button>
            </div>
        </el-dialog>
    </section>
</template>

<script>
export default {
    name: "ChangeGoodsType",
    props: {
        typeList: {
            type: Array,
            required: true
        }
    },
    data() {
        return {
            dialogVisible: false,
            type_name: ''
        };
    },

    mounted() {},

    methods: {

        /**
         * 显示弹窗
         */
        show(type_name) {
            this.type_name = type_name;
            this.dialogVisible = true;
        },

        /**
         * 关闭弹窗
         */
        close() {
            this.dialogVisible = false;
        },

        /**
         * @description 弹窗关闭清空数据
         */
        handleClose() {
            this.type_name = '';
        },

        /**
         * 提交
         */
        handleConfirm() {
            this.$emit('confirm', this.type_name ? this.type_name[this.type_name.length - 1] : '');
        }
    }
};
</script>

<style scoped lang="less">
.wrapper {
    /deep/ .el-dialog__header {
        padding-top: 10px;
        box-shadow:0 1px 0 0 rgba(233,233,233,1);
        display: flex;
        align-items: center;
        background: #FAFAFA;
        border-radius: 4px 4px 0 0;
        .el-dialog__title {
            font-weight: 500;
            color: #333;
            font-size: 14px;
        }
        .el-icon-close:before {
            color: rgb(194,194,194);
            font-size: 17px;
            font-weight: bold;
        }
        .el-dialog__headerbtn {
            top: 14px;
        }
    }
    /deep/ .el-dialog__body {
        padding: 24px 32px;
    }
    .dialog-footer {
        display: flex;
        justify-content: center;
    }
    .form-item {
        display: flex;
        align-items: center;
        margin-bottom: 24px;
    }
}
</style>
